package com.zygame.sdk.view;

import java.util.ArrayList;
import java.util.Map;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.zygame.sdk.utils.res.ResourceUtil;

public class DeleteNameDailog extends BaseDialog implements android.view.View.OnClickListener{

	private Context mContext;
	
	private TextView delete;
	private Button positive;
	private Button negative;
	private Handler mHandler;
	private int mPosition;
	private ArrayList<Map<String,String>> mList;
	
	
	public DeleteNameDailog(Context context,ArrayList<Map<String,String>> list,Handler handler,int position) {
		super(context,280,150);     //设置宽高
		
		this.mContext = context;
		this.mHandler = handler;
		this.mPosition = position;
		this.mList = list;
		this.setCanceledOnTouchOutside(false);
	}

	@Override
	protected void subOnCreate() {
		setContentView(ResourceUtil.getLayoutId(mContext, "fy_ly_dialog_delete_name"));
		init(mContext);
	}
	
	private void init(Context context){
		delete = (TextView) findViewById(ResourceUtil.getId(mContext, "delete"));
		positive = (Button) findViewById(ResourceUtil.getId(mContext, "positive"));
		negative = (Button) findViewById(ResourceUtil.getId(mContext, "negative"));
		if(mList != null){
//			delete.setText("您确定要删除65的账号" + mList.get(mPosition).entrySet().iterator().next().getKey() + "?");
			delete.setText( mList.get(mPosition).entrySet().iterator().next().getKey());
		}
		
		delete.setOnClickListener(this);
		positive.setOnClickListener(this);
		negative.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		int viewId = v.getId();
		
		if(viewId == ResourceUtil.getId(mContext, "positive")){
			
			Message msg = new Message();
			Bundle data = new Bundle();
			//设置删除索引
			data.putInt("delIndex", mPosition);
			msg.setData(data);
			msg.what = 2;
			//发出消息
			mHandler.sendMessage(msg);
			DeleteNameDailog.this.dismiss();
		}else if(viewId == ResourceUtil.getId(mContext, "negative")){
			DeleteNameDailog.this.dismiss();
		}
	}
	
}
